package com.xxf.aynu.parking;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.List;


/**
 * Created by Rossoneri on 2017/5/10 0010.
 */
public class newlogin extends Activity {

    public static final String INFO_USER_NAME = "INFO_USER_NAME";
    public static final String INFO_PER_SIGN = "INFO_PER_SIGN";

    Button btn_login;
    TextView text;
    @Override
    protected void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);



        text=(TextView)findViewById(R.id.login_regist);
        text.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent();
                intent.setClass(getApplicationContext(), newregister.class);
                //item.setIntent(intent);
                startActivity(intent);
            }
        });
        btn_login=(Button)findViewById(R.id.login_login);
        btn_login.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EditText uname1 =(EditText)findViewById(R.id.login_et_name);
                String uname=uname1.getText().toString();
                EditText pw1 =(EditText)findViewById(R.id.login_et_password);
                String pw=pw1.getText().toString();
                String httpUrl = "http://114.115.141.26/ParkingCar/UserLogin";
                String httpArg="Utel="+uname+"&"+"Upassword="+pw;
                if(uname.length()>0&&pw.length()>0)
                {
                    String str=Te.main(httpArg);
                   // Toast.makeText(getApplicationContext(),"欢迎回来!", Toast.LENGTH_SHORT).show();

                    Intent intent=new Intent();
                    intent.putExtra(INFO_USER_NAME, uname);
                    intent.putExtra(INFO_PER_SIGN, pw);
                    intent.setClass(getApplicationContext(), waiting_activity.class);
                    startActivity(intent);
                    finish();


                    /*String y="Yes";

                    if(y.equals(str))//登陆成功
                    {
                    }
                    else
                        Toast.makeText(getApplicationContext(),"登录失败", Toast.LENGTH_SHORT).show();*/

                }
                else
                {
                    Toast.makeText(getApplicationContext(),"用户名或密码不能为空!", Toast.LENGTH_SHORT).show();
                }
            }
        });



    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }





}


